package chapter1.view;

import chapter1.util.SingletonFactory;

import java.util.Scanner;

public class MainView {
    public static final String MENU = """
            -------------
               RBAC系统
            -------------
            | 0 退出系统  |
            | 1 管理模式  |
            | 2 员工模式  |
            -------------
            请输入选项：""";
    //输出主界面菜单
    public static Scanner input;


    static {
        input = new Scanner(System.in);
    }


    private final ManageMode manageMode;
    private final UserMode userMode;


    private MainView() {
        userMode = SingletonFactory.getInstance(UserMode.class);
        manageMode=SingletonFactory.getInstance(ManageMode.class);
    }



    public void show() {
        String menuChoice;
        do {
            System.out.print(MENU);
            menuChoice = input.nextLine();
            switch (menuChoice) {
                case "0" -> System.out.println("成功退出系统，欢迎再次使用！");
                case "1" -> manageMode.show();
                case "2" -> userMode.show();
                default -> System.out.print("输入非法，请输入正确的菜单编号！");
            }
        } while (!"0".equals(menuChoice));
        input.close();
    }


}
